<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- 
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License. 
-->
<html>
<head>
    <link type="text/css" rel="stylesheet" href="https://struts.apache.org/css/default.css">
    <style type="text/css">
        .dp-highlighter {
            width:95% !important;
        }
    </style>
    <style type="text/css">
        .footer {
            background-image:      url('https://cwiki.apache.org/confluence/images/border/border_bottom.gif');
            background-repeat:     repeat-x;
            background-position:   left top;
            padding-top:           4px;
            color:                 #666;
        }
    </style>
    <link href='https://struts.apache.org/highlighter/style/shCoreStruts.css' rel='stylesheet' type='text/css' />
    <link href='https://struts.apache.org/highlighter/style/shThemeStruts.css' rel='stylesheet' type='text/css' />
    <script src='https://struts.apache.org/highlighter/js/shCore.js' type='text/javascript'></script>
    <script src='https://struts.apache.org/highlighter/js/shBrushPlain.js' type='text/javascript'></script>
    <script src='https://struts.apache.org/highlighter/js/shBrushXml.js' type='text/javascript'></script>
    <script src='https://struts.apache.org/highlighter/js/shBrushJava.js' type='text/javascript'></script>
    <script src='https://struts.apache.org/highlighter/js/shBrushJScript.js' type='text/javascript'></script>
    <script src='https://struts.apache.org/highlighter/js/shBrushGroovy.js' type='text/javascript'></script>
    <script src='https://struts.apache.org/highlighter/js/shBrushBash.js' type='text/javascript'></script>
    <script type="text/javascript">
        SyntaxHighlighter.defaults['toolbar'] = false;
        SyntaxHighlighter.all();
    </script>
    <script type="text/javascript" language="javascript">
        var hide = null;
        var show = null;
        var children = null;

        function init() {
            /* Search form initialization */
            var form = document.forms['search'];
            if (form != null) {
                form.elements['domains'].value = location.hostname;
                form.elements['sitesearch'].value = location.hostname;
            }

            /* Children initialization */
            hide = document.getElementById('hide');
            show = document.getElementById('show');
            children = document.all != null ?
                    document.all['children'] :
                    document.getElementById('children');
            if (children != null) {
                children.style.display = 'none';
                show.style.display = 'inline';
                hide.style.display = 'none';
            }
        }

        function showChildren() {
            children.style.display = 'block';
            show.style.display = 'none';
            hide.style.display = 'inline';
        }

        function hideChildren() {
            children.style.display = 'none';
            show.style.display = 'inline';
            hide.style.display = 'none';
        }
    </script>
    <title>Struts 2 Blank Archetype</title>
</head>
<body onload="init()">
<table border="0" cellpadding="2" cellspacing="0" width="100%">
    <tr class="topBar">
        <td align="left" valign="middle" class="topBarDiv" align="left" nowrap>
            &nbsp;<a href="home.html">Home</a>&nbsp;&gt;&nbsp;<a href="guides.html">Guides</a>&nbsp;&gt;&nbsp;<a href="core-developers-guide.html">Core Developers Guide</a>&nbsp;&gt;&nbsp;<a href="struts-2-maven-archetypes.html">Struts 2 Maven Archetypes</a>&nbsp;&gt;&nbsp;<a href="struts-2-blank-archetype.html">Struts 2 Blank Archetype</a>
        </td>
        <td align="right" valign="middle" nowrap>
            <form name="search" action="https://www.google.com/search" method="get">
                <input type="hidden" name="ie" value="UTF-8" />
                <input type="hidden" name="oe" value="UTF-8" />
                <input type="hidden" name="domains" value="" />
                <input type="hidden" name="sitesearch" value="" />
                <input type="text" name="q" maxlength="255" value="" />
                <input type="submit" name="btnG" value="Google Search" />
            </form>
        </td>
    </tr>
</table>

<div id="PageContent">
    <div class="pageheader" style="padding: 6px 0px 0px 0px;">
        <!-- We'll enable this once we figure out how to access (and save) the logo resource -->
        <!--img src="/wiki/images/confluence_logo.gif" style="float: left; margin: 4px 4px 4px 10px;" border="0"-->
        <div style="margin: 0px 10px 0px 10px" class="smalltext">Apache Struts 2 Documentation</div>
        <div style="margin: 0px 10px 8px 10px"  class="pagetitle">Struts 2 Blank Archetype</div>

        <div class="greynavbar" align="right" style="padding: 2px 10px; margin: 0px;">
            <a href="https://cwiki.apache.org/confluence/pages/editpage.action?pageId=108834">
                <img src="https://cwiki.apache.org/confluence/images/icons/notep_16.gif"
                     height="16" width="16" border="0" align="absmiddle" title="Edit Page"></a>
            <a href="https://cwiki.apache.org/confluence/pages/editpage.action?pageId=108834">Edit Page</a>
            &nbsp;
            <a href="https://cwiki.apache.org/confluence/pages/listpages.action?key=WW">
                <img src="https://cwiki.apache.org/confluence/images/icons/browse_space.gif"
                     height="16" width="16" border="0" align="absmiddle" title="Browse Space"></a>
            <a href="https://cwiki.apache.org/confluence/pages/listpages.action?key=WW">Browse Space</a>
            &nbsp;
            <a href="https://cwiki.apache.org/confluence/pages/createpage.action?spaceKey=WW&fromPageId=108834">
                <img src="https://cwiki.apache.org/confluence/images/icons/add_page_16.gif"
                     height="16" width="16" border="0" align="absmiddle" title="Add Page"></a>
            <a href="https://cwiki.apache.org/confluence/pages/createpage.action?spaceKey=WW&fromPageId=108834">Add Page</a>
            &nbsp;
            <a href="https://cwiki.apache.org/confluence/pages/createblogpost.action?spaceKey=WW&fromPageId=108834">
                <img src="https://cwiki.apache.org/confluence/images/icons/add_blogentry_16.gif"
                     height="16" width="16" border="0" align="absmiddle" title="Add News"></a>
            <a href="https://cwiki.apache.org/confluence/pages/createblogpost.action?spaceKey=WW&fromPageId=108834">Add News</a>
        </div>
    </div>

    <div class="pagecontent">
        <div class="wiki-content">
            <div id="ConfluenceContent"><p>
</p><p>The Struts 2 Blank Archetype ("blank-archetype") provides a minimal, but complete, Struts 2 application. It demonstrates some of the most basic Struts 2 concepts.</p>

<h4 id="Struts2BlankArchetype-Features">Features</h4>

<ul><li>XML-based configuration, demonstrates including additional config file</li><li>Example actions</li><li>Package-level resource bundle</li><li>XML-based validation</li><li>Unit-testing</li></ul>


<p><strong>Contents</strong></p>

<style type="text/css">/*<![CDATA[*/
div.rbtoc1440489278291 {padding: 0px;}
div.rbtoc1440489278291 ul {list-style: none;margin-left: 0px;padding-left: 1em;}
div.rbtoc1440489278291 li {margin-left: 0px;padding-left: 0px;}

/*]]>*/</style><div class="toc-macro rbtoc1440489278291">
<ul class="toc-indentation"><li><span class="TOCOutline">1</span> <a shape="rect" href="#Struts2BlankArchetype-CreatingOurblank-archetypeProject">Creating Our blank-archetype Project</a>
<ul class="toc-indentation"><li><span class="TOCOutline">1.1</span> <a shape="rect" href="#Struts2BlankArchetype-Stagingrepository">Staging repository</a></li></ul>
</li><li><span class="TOCOutline">2</span> <a shape="rect" href="#Struts2BlankArchetype-ProjectStructure">Project Structure</a>
<ul class="toc-indentation"><li><span class="TOCOutline">2.1</span> <a shape="rect" href="#Struts2BlankArchetype-StructureDifferenceFromNon-MavenProjects">Structure Difference From Non-Maven Projects</a></li></ul>
</li><li><span class="TOCOutline">3</span> <a shape="rect" href="#Struts2BlankArchetype-BuildingTheProject">Building The Project</a>
<ul class="toc-indentation"><li><span class="TOCOutline">3.1</span> <a shape="rect" href="#Struts2BlankArchetype-Compilation">Compilation</a></li><li><span class="TOCOutline">3.2</span> <a shape="rect" href="#Struts2BlankArchetype-Testing">Testing</a></li><li><span class="TOCOutline">3.3</span> <a shape="rect" href="#Struts2BlankArchetype-Assembling(CreatingaWAR)">Assembling (Creating a WAR)</a></li><li><span class="TOCOutline">3.4</span> <a shape="rect" href="#Struts2BlankArchetype-Running">Running</a></li></ul>
</li><li><span class="TOCOutline">4</span> <a shape="rect" href="#Struts2BlankArchetype-ApplicationDocumentation">Application Documentation</a>
<ul class="toc-indentation"><li><span class="TOCOutline">4.1</span> <a shape="rect" href="#Struts2BlankArchetype-ApplicationConfiguration">Application Configuration</a></li><li><span class="TOCOutline">4.2</span> <a shape="rect" href="#Struts2BlankArchetype-Welcome.action">Welcome.action</a></li><li><span class="TOCOutline">4.3</span> <a shape="rect" href="#Struts2BlankArchetype-HelloWorld.action">HelloWorld.action</a></li><li><span class="TOCOutline">4.4</span> <a shape="rect" href="#Struts2BlankArchetype-Login.action">Login.action</a></li></ul>
</li></ul>
</div>

<h2 id="Struts2BlankArchetype-CreatingOurblank-archetypeProject">Creating Our blank-archetype Project</h2>

<p>We'll run the following command from our project's parent directory (this is shown using Unix-style commands).</p>

<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">
$ mvn archetype:generate -B \
                         -DgroupId=tutorial \
                         -DartifactId=tutorial \
                         -DarchetypeGroupId=org.apache.struts \
                         -DarchetypeArtifactId=struts2-archetype-blank \
                         -DarchetypeVersion=&lt;version&gt;
$ ls
tutorial/
$ cd tutorial
$ ls
pom.xml         src/
</pre>
</div></div>

<p>Depending on the state of your local system you may see Maven downloading various libraries (known as "downloading the internet", which is what it seems Maven does sometimes). Be patient--Maven is basically setting up your required libraries automatically.<br clear="none">
<strong>&lt;version&gt;</strong> - is the version of Struts 2 you want to use and archetype was released for, eg. 2.1.8.1 .</p>

<h3 id="Struts2BlankArchetype-Stagingrepository">Staging repository</h3>

<p>If the above command will fail because of missing archetypes in central repository, you can try to use staging repository like below</p>

<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">
mvn archetype:generate -B \
                       -DgroupId=tutorial \
                       -DartifactId=tutorial \
                       -DarchetypeGroupId=org.apache.struts \
                       -DarchetypeArtifactId=struts2-archetype-blank \
                       -DarchetypeVersion=&lt;version&gt;
                       -DarchetypeCatalog=http://people.apache.org/builds/struts/&lt;version&gt;/m2-staging-repository/ 
</pre>
</div></div>

<h2 id="Struts2BlankArchetype-ProjectStructure">Project Structure</h2>

<p>The source code structure follows the normal <a shape="rect" class="external-link" href="http://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html">Maven directory structure</a>. The blank-archetype does not include all of the directories listed in the Maven structure reference page.</p>

<p>Our project's structure looks like this:</p>

<div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p> Directory </p></th><th colspan="1" rowspan="1" class="confluenceTh"><p> Description</p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> <code>src</code> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> All project source</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> <code>&#166;- main</code> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Primary source directory</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> <code>&#166;&#160;&#160;&#166;- java</code> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Java source code</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> <code>&#166;&#160;&#160;&#166;&#160;&#160;`- tutorial</code> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Package defined by <code>groupId</code> parameter</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> <code>&#166;&#160;&#160;&#166;&#160;&#160;&#160;&#160;&#160;`- example</code> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> The example actions from the archetype</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> <code>&#166;&#160;&#160;&#166;- resources</code> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Resources (config, property, and validation files, and so on</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> <code>&#166;&#160;&#160;&#166;&#160;&#160;`-tutorial</code> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Package defined by <code>groupId</code> parameter</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> <code>&#166;&#160;&#160;&#166;&#160;&#160;&#160;&#160;&#160;`- example</code> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Example property and validation files from archetype</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> <code>&#166;&#160;&#160;`- webapp</code> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Web application files (HTML, JSP, etc.)</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> <code>&#166;&#160;&#160;&#160;&#160;&#160;&#160;`- WEB-INF</code> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Typical WEB-INF folder</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> <code>&#166;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;`- example</code> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Files from archetype</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> <code>`- test</code> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Test code (unit tests etc.)</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> <code>&#160;&#160;&#160;`- java</code> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Java-based test code</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> <code>&#160;&#160;&#160;&#160;&#160;&#160;`- tutorial</code> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Package defined by <code>groupId</code> parameter</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> <code>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;`- example</code> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Test code from archetype</p></td></tr></tbody></table></div>


<h3 id="Struts2BlankArchetype-StructureDifferenceFromNon-MavenProjects">Structure Difference From Non-Maven Projects</h3>

<p>One big change for folks not used to the Maven structure is the separation of Java source code and resource files. For example, in a non-Maven project our directory structure might look like this:</p>

<div class="table-wrap"><table class="confluenceTable"><tbody><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> <code>src</code> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> All project source</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> <code>&#166;- tutorial</code> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Tutorial package</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> <code>&#166;&#160;&#160;`- example</code> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Example package</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> <code>&#166;&#160;&#160;&#160;&#160;&#160;&#166;- Login.java</code> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Login action source</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> <code>&#166;&#160;&#160;&#160;&#160;&#160;&#166;- package.properties</code> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Resource file</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> <code>&#166;&#160;&#160;&#160;&#160;&#160;`- Login-validation.xml</code> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Validation file</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> <code>`- struts.xml</code> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Struts 2 config file</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> <code>web</code> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Web app files</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> <code>&#166;- WEB-INF</code> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Typical WEB-INF folder</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> <code>`- index.html</code> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> An HTML file</p></td></tr></tbody></table></div>


<p>It can take a little while to get used to, but ultimately it provides good separation of "types" of things, and becomes second-nature pretty quickly. Note that it's possible to use a non-Maven directory layout with Maven projects, but this can be challenging at some points.</p>

<h2 id="Struts2BlankArchetype-BuildingTheProject">Building The Project</h2>

<p>There are several different ways we can go about building our project, from simple compilation up to actually running the web application--all from within Maven.</p>

<h3 id="Struts2BlankArchetype-Compilation">Compilation</h3>

<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">$ mvn compile</pre>
</div></div>

<p>will create a <code>target</code> directory containing the compiled classes. By itself this isn't terribly useful.</p>


<h3 id="Struts2BlankArchetype-Testing">Testing</h3>

<p>Running</p>

<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">$ mvn test</pre>
</div></div>

<p>will compile the application and run the included unit tests. Blank-archetype's unit tests are <em>not</em> extensive, but provide a simple starting point for writing more complex, application-specific tests.</p>

<p>One we've run the Maven test command we'll notice there's a <code>target/surefire-reports</code> directory. The <a shape="rect" class="external-link" href="http://maven.apache.org/plugins/maven-surefire-plugin/">Maven Surefire Plugin</a> is how Maven runs our unit tests. By default it will create test results in XML and text formats in the <code>target/surefire-reports</code> directory. These files can be examined to get further information regarding the failed tests.</p>

<h3 id="Struts2BlankArchetype-Assembling(CreatingaWAR)">Assembling (Creating a WAR)</h3>

<h3 id="Struts2BlankArchetype-Running">Running</h3>

<p>We can run blank-archetype using the <a shape="rect" class="external-link" href="http://www.mortbay.org/jetty/" rel="nofollow">Jetty</a> server via the <a shape="rect" class="external-link" href="http://docs.codehaus.org/display/JETTY/Maven+Jetty+Plugin" rel="nofollow">Maven Jetty Plugin</a> by executing the Jetty plugin's <code>run</code> command:</p>

<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">$ mvn jetty:run</pre>
</div></div>

<p>Once we've run the application we can see that it works by visiting <code>localhost:8080/tutorial/example/Welcome.action</code> as a sanity check.</p>

<h2 id="Struts2BlankArchetype-ApplicationDocumentation">Application Documentation</h2>

<p>The application consists of a few test actions demonstrating simple validation and package-level property (resource) files. The most interesting URLs are as follows (assuming we used <code>groupId=tutorial</code>):</p>

<div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p> URL </p></th><th colspan="1" rowspan="1" class="confluenceTh"><p> Description</p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> <code>/tutorial/example/Welcome.action</code> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Handled by wildcard mapping</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> <code>/tutorial/example/HelloWorld.action</code> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Handled by explicit mapping, demonstrates package-level properties</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> <code>/tutorial/example/Login.action</code> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Handled by explicit mapping with method wilcard (see the <code>Login.action</code> documentation for information regarding how to access this URL)</p></td></tr></tbody></table></div>


<h3 id="Struts2BlankArchetype-ApplicationConfiguration">Application Configuration</h3>

<p>The default Struts 2 configuration file is contained in <code>src/main/resources/struts.xml</code>. It includes an additional configuration file, <code>src/main/resources/example.xml</code>. The application's mappings are contained in the <code>example.xml</code> file. The <code>struts.xml</code> file sets some constants.</p>

<p>See the <a shape="rect" href="strutsxml.html">struts.xml</a> page for more information about the <code>struts.xml</code> file. For more information regarding what's contained in typical <code>struts.xml</code> files start at the <a shape="rect" href="configuration-elements.html">Configuration Elements</a> page, which contains links to a bunch of information. See the <a shape="rect" href="configuration-files.html">Configuration Files</a> page for more information regarding additional Struts 2 configuration files, including links to the files that set all the Struts 2 default configurations.</p>

<h3 id="Struts2BlankArchetype-Welcome.action"><code>Welcome.action</code></h3>

<p>The mapping for this action is handled by a "catch-all" mapping in <code>example.xml</code>:</p>

<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">
&lt;action name="*" class="tutorial2.example.ExampleSupport"&gt;
  &lt;result&gt;/example/{1}.jsp&lt;/result&gt;
&lt;/action&gt;
</pre>
</div></div>

<p>This mapping is the last mapping contained in <code>example.xml</code>--anything not handled by mappings appearing before it in <code>example.xml</code> will be caught by this mapping. This mapping will look for JSP files in <code>src/main/webapp/example/*.jsp</code>. Since there's a <code>Welcome.jsp</code> in that directory, we're all set. See the <a shape="rect" href="wildcard-mappings.html">Wildcard Mappings</a> page for more information on how Struts 2 can use wildcard mappings.</p>

<h3 id="Struts2BlankArchetype-HelloWorld.action"><code>HelloWorld.action</code></h3>

<p>The mapping executes the HelloWorld action, contained in <code>src/main/java/tutorial/example/HelloWorld.action</code>. This action retrieves a message from a package-level properties file, contained in <code>src/main/resources/tutorial/package.properties</code>. See the <a shape="rect" href="localization.html">Localization</a> page for more information about how Struts 2 handles message resources (it's pretty cool).</p>

<h3 id="Struts2BlankArchetype-Login.action"><code>Login.action</code></h3>

<p>This is another wildcard mapping:</p>

<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">
&lt;action name="Login_*" method="{1}" class="tutorial2.example.Login"&gt;
  &lt;result name="input"&gt;/example/Login.jsp&lt;/result&gt;
  &lt;result type="redirectAction"&gt;Menu&lt;/result&gt;
&lt;/action&gt;
</pre>
</div></div>

<p>In the application the Login action is reached via a link, but not directly to <code>/tutorial/example/Login.action</code>. The link is actually <code>/tutorial/example/Login_input.action</code>. Reaching the Login action this way bypasses validation: if we hit the Login action directly we'll get a validation error.</p>

<p>The validation configuration is contained in <code>/src/main/resources/tutorial/example/Login-validation.xml</code>. It checks for the presence of the <code>username</code> and <code>password</code> properties (form values). It uses messages stored in the <code>package.properties</code> file (in the same directory). See the <a shape="rect" href="validation.html">Validation</a> page for more information regarding Struts 2 validation.</p></div>
        </div>

        
    </div>
</div>
<div class="footer">
    Generated by CXF SiteExporter
</div>
</body>
</html>
